#include "LineParser.h"

#include "LineHandler.h"

cbsocket::LineParser::LineParser(cbsocket::LineHandler* handler):
handler(handler),
line()
{
}

cbsocket::LineParser::~LineParser()
{
    delete handler;
}

void cbsocket::LineParser::processData(const void* data_, size_t size)
{
    char const* data = static_cast<char const*>(data_);
    for(size_t i = 0; i < size; ++i)
    {
        char const c = data[i];
        if(c == '\n')
        {
            handler->pushLine(line);
            line.clear();
        }
        else
            line += c;
    }
}
